// import request from "@/utils/request.js";
// import Cache from "@/utils/cache.js"
import request from '@/config/minRequest.js'
const url = '/customer'
/**
 * 商品列表查询  客户小程序查询商品列表（渠道价）
 */
// export function getGoodsListApi(data) {
//   return request.post(url + '/v103/mall/goods/getList', data);
// }
export function getGoodsListApi(data) {
	return request.post(url + '/v103/mall/goods/getGoodsListWithDiscount', data);
}
// 刚进入未登录时掉下面这个接口
export function getGoodsListApiNologin(data) {
	return request.post(url + '/v103/mall/goods/open/defaultProductList', data);
}
/**
 * 查询商品类别列表
 */
export function getGoodsTypeListApi(tenantId) {
	// return request.get(url + '/v103/mall/goodsType/getList', data);
	return request.get(url + `/open/cus/product_category/listProductCategoryTree/${tenantId}`);
}

//查询商品顶级分类列表
export function getGoodsTopTypeListApi(tenantId,parentId) {
	return request.get(url + `/open/cus/product_category/listRootProductCategory/${tenantId}?parentId=${parentId}`);
}

export function getGoodsOpenTypeListApi(tenantId) {
	return request.get(url + `/open/cus/product_category/listProductCategoryTree/${tenantId}`);
}
/**
 * 客户端小程序 - 1.0.3根据板块类型code查询该板块轮播图
 */
export function getListConfigBanner(plateType,tenantId) {
	return request.get(url + `/open/indexMallBanner/listConfigBanner/${plateType}/${tenantId}`);
}
/**
 * 客户端小程序 - 1.0.3根板块轮播图获取详情
 */
export function getConfigBannerInfo(id) {
	return request.get(url + `/open/indexMallBanner/getConfigBannerInfo/${id}`);
}
/**
 *  收藏商品
 */
export function collectGoods(goodsId) {
	return request.post(url + `/v103/mall/goodsCollection/${goodsId}`);
}

/**
 *  取消收藏
 */
export function deleteCollect(goodsId) {
	return request.delete(url + `/v103/mall/goodsCollection/${goodsId}`);
}

/**
 * 收藏列表
 */
export function collectList(data) {
	return request.get(url + `/v103/mall/goodsCollection/upList`, data);
}

/**
 * 收藏失效
 */
export function getInvalidListApi(data) {
	return request.get(url + `/v103/mall/goodsCollection/downList`, data);
}

/**
 *  清空收藏
 */
export function clearList(goodsId) {
	return request.delete(url + `/v103/mall/goodsCollection/clear`);
}

/**
 * 根据商品ID获取商品详情  增加渠道价
 * @param id:string
 */
// export const getGoodsDetail = async (id) => {
//   return request.get(url + `/v103/mall/goods/${id}`)
// }
export const getGoodsDetail = async (id, tenantId) => {
	return request.get(url + `/v103/mall/goods/getGoodsInfoWithTenantId/${id}/${tenantId}`)
}
/**
 * 根据商品ID获取商品详情  增加渠道价
 * @param id:string
 */
export const getGoodsDetailAuth = async (id) => {
	return request.get(url + `/v103/mall/goods/open/auth/${id}`)
}
// export const getGoodsDetailAuth = async (id, tenantId) => {
// 	return request.get(url + `/v103/mall/goods/open/getGoodsInfoWithTenantId/${id}/${tenantId}`)
// }

/**
 * 规格中的默认地址
 */
export function getDefaultShippingAddress(data) {
	return request.get(url + `/shippingAddress/getDefaultShippingAddress`, data);
}

/**
 * 收货地址列表
 */
export function getShippingAddress(data) {
	return request.post(url + '/shippingAddress/list', data);
}

/**
 * 添加收货地址
 */
export function addAddress(data) {
	return request.post(url + '/shippingAddress/add', data);
}

/**
 *  删除地址
 */
export function deleteAddress(id) {
	return request.delete(url + `/shippingAddress/delete/${id}`);
}

/**
 * 根据ID获取地址详情
 * @param id:string
 */
export const getAddressDetail = async (id) => {
	return request.get(url + `/shippingAddress/getById/${id}`)
}

/**
 * 修改收货地址
 */
export function editAddress(data) {
	return request.post(url + '/shippingAddress/update', data);
}
export function editAddressIdForOrder(data) {
	return request.post(url + '/shippingAddress/changeAddressIdForOrder', data);
}

/**
 * 修改默认地址
 */
export function editDefaultAddress(id) {
	return request.post(url + `/shippingAddress/changeDefaultAddress/${id}`);
}

// 根据客户ID以及商品ID查询优选产品价格
export const getDiscountedPrice = (params) => request.post(`${url}/channel_price/getThePriceOfTheCustomerGoods`, params)

// 创建客户商品

export const createCustomerGoods = (params) => request.post(`${url}/v103/mall/goods/createCustomerGoods`, params)
export const updateCustomerGoods = (params) => request.post(`${url}/v103/mall/goods/updateCustomerGoods`, params)
// 查询客户商品列表

export const getCustomerGoodsList = async (params) => {
	return request.get(url + `/v103/mall/goods/getCustomerGoodsList`, params)
}
export const getCustomerGoodsListNoToken = async (params) => {
	return request.get(url + `/v103/mall/goods/open/getCustomerGoodsListNoToken`, params)
}
export const getCustomerGoodsInfo = async (id) => {
	return request.get(url + `/v103/mall/goods/getCustomerGoodsInfo/${id}`)
}
// removeCustomerGoods

export const removeCustomerGoods = (id) => request.post(`${url}/v103/mall/goods/removeCustomerGoods/${id}`)
// 下架上架
export const updateCustomerGoodsStatus = (params) => request.post(`${url}/v103/mall/goods/updateCustomerGoodsStatus`, params)

//添加到购物车
export function addShoppingCart(data) {
	return request.post(url + '/shopping_cart/addShoppingCart', data);
}

//查询购物车列表
export function listShoppingCart(data) {
	return request.post(url + '/shopping_cart/listShoppingCartNoPage', data);
}

//购物车确认订单
export function confirmOrderShoppingCart(data) {
	return request.post(url + '/v103/order/confirmOrderShoppingCart', data);
}

//修改购物车商品数量
export function updateShoppingCart(data) {
	return request.post(url + '/shopping_cart/updateShoppingCart', data);
}

//创建调查问卷表单
export function createFormRecord(data) {
	return request.post(url + '/formRecord/create', data);
}

